package kr.hkit.powerjava.chapter10.submit;

import java.util.Scanner;

class Average {

	private int[] scores;

	public Average(int student) {
		scores = new int[student]; //?? 생성자.
	}

	Scanner input = new Scanner(System.in);

	public void getValues() {
		int jumsu = 0;
		for (int i = 0; i < scores.length; i++) {
			System.out.print("학생" + (i + 1) + "의 성적을 입력하시오: ");
			jumsu = input.nextInt();

			if (jumsu < 0 || jumsu > 100) {
				System.out.println("잘못된 성적입니다. 다시 입력하시오.");
				i--;

			} else {
				scores[i] = jumsu;
			}
		}
	}

	public void getAverage() {
		double total = 0;
		for (int i = 0; i < scores.length; i++) {
			total += scores[i];
		}
		System.out.println("성적 평균은 " + total / scores.length + "입니다.");
	}
}
